package com.polytech.ihm;

import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class LabeledTextField  extends JPanel{
	private JLabel label;
	private JTextField textfield;
	
	public LabeledTextField(String caption, int size) {
		setLayout(new FlowLayout(FlowLayout.LEFT));
		label =new JLabel(caption + " : ");
		label.setPreferredSize(new Dimension(100,20));
		textfield =new JTextField(size);
		add(label);
		add(textfield);
	}
	public LabeledTextField(String caption, int size ,int labelw) {
		setLayout(new FlowLayout(FlowLayout.LEFT));
		if(!caption.contains(":")) caption= caption+ " : ";
		label =new JLabel(caption);
		label.setPreferredSize(new Dimension(labelw,label.getPreferredSize().height));
		textfield =new JTextField(size);
		add(label);
		add(textfield);
	}
	public String getValue() {
	
		return textfield.getText();
		
	}
	
	public void setValue(String text) {
		
		textfield.setText(text);
	}
}
